package tech.aistar.day06.homework02;

import java.util.Date;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2021/3/16 9:14 上午
 */
public class HourlyEmployee extends Employee{
    //属性：每小时的工资、每月工作的小时数
    private double salary;

    private int hours;

    public HourlyEmployee(String name, Date birthday, double salary, int hours) {
        super(name, birthday);
        this.salary = salary;
        this.hours = hours;
    }

    @Override
    public double getSalary(int month) {
        //每月工作超出160小时的部分按照1.5倍工资发放。
        double total = salary * hours;

        if(hours>160){
            total+=(hours-160)*0.5;
        }

        return super.getSalary(month)+total;
    }
}
